package com.lottery.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lottery.entity.LotteryParticipation;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface LotteryParticipationMapper extends BaseMapper<LotteryParticipation> {
    
    /**
     * 查询用户今日参与次数
     */
    @Select("SELECT COUNT(*) FROM lottery_participation " +
            "WHERE user_id = #{userId} AND activity_id = #{activityId} " +
            "AND DATE(participate_time) = CURDATE()")
    int countTodayParticipation(Integer userId, Integer activityId);
    
    /**
     * 查询用户总参与次数
     */
    @Select("SELECT COUNT(*) FROM lottery_participation " +
            "WHERE user_id = #{userId} AND activity_id = #{activityId}")
    int countTotalParticipation(Integer userId, Integer activityId);
} 